<?php
/**
 * Copyright (c) 2006-2008, Julien PORTALIER
 * http://featherphp.googlecode.com/
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 */

$var = Inflector::tableize($this->model_class);
if (isset($this->{$var}))
{
	foreach($this->{$var} as $i => $v)
	{
		if ($v instanceof Object) {
			$this->{$var}[$i] = $v->to_json();
		}
		else {
			$this->{$var}[$i] = json_encode($v);
		}
	}
	echo '['.implode(', ', $this->{$var}).']';
}
elseif (isset($this->{$this->model_class})) {
	echo $this->{$this->model_class}->to_json();
}
?>